﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:view="clr-namespace:Blackbird.Studio.View"
                    xmlns:ctrl="clr-namespace:Blackbird.Studio.Control"
                    xmlns:entity="clr-namespace:Blackbird.Studio.ViewModel.EntityViewModels"
                    xmlns:mvvm="clr-namespace:Blackbird.Studio.Mvvm"
                    xmlns:vm="clr-namespace:Blackbird.Studio.ViewModel">

    <vm:DesignerViewModel x:Key="StaticViewModel" />
    <ctrl:ImageGridDesignerViewModel x:Key="StaticImageGridViewModel" />

    <DropShadowEffect x:Key="ShadowEffect" BlurRadius="2.0" Color="Black" />

    <SolidColorBrush x:Key="HeaderBackgroundBrush" Color="LightGray" />
    <SolidColorBrush x:Key="ListBackgroundBrush" Color="#FFFFBF7D" />
    <SolidColorBrush x:Key="ToolsBackgroundBrush" Color="LightGray" />

    <LinearGradientBrush x:Key="MetalGradientBrush" StartPoint="0.0, 0.0" EndPoint=" 0.5, 1.0">
        <GradientStop Offset="0.1" Color="SlateGray" />
        <GradientStop Offset="0.25" Color="LightGray" />
        <GradientStop Offset="0.60" Color="SlateGray" />
        <GradientStop Offset="1.0" Color="SlateGray" />
    </LinearGradientBrush>

    <Style x:Key="MainBorderStyle" TargetType="{x:Type Border}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="Black" />
        <Setter Property="Background" Value="{StaticResource MetalGradientBrush}" />
        <Setter Property="Margin" Value="4" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="CornerRadius" Value="5" />
    </Style>

    <Style x:Key="HeaderBorderStyle" TargetType="Border" BasedOn="{StaticResource MainBorderStyle}">
        <Setter Property="Background" Value="{StaticResource HeaderBackgroundBrush}" />
        <Setter Property="Padding" Value="4, 4, 4, 4" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Effect" Value="{StaticResource ShadowEffect}" />
    </Style>

    <Style x:Key="ListBorderStyle" TargetType="Border" BasedOn="{StaticResource MainBorderStyle}">
        <Setter Property="Background" Value="{StaticResource ListBackgroundBrush}" />
    </Style>

    <Style x:Key="ToolsBorderStyle" TargetType="Border" BasedOn="{StaticResource MainBorderStyle}">
        <Setter Property="Background" Value="{StaticResource ToolsBackgroundBrush}" />
        <!--Padding="4, 8, 4, 8" Margin="4"-->
        <Setter Property="Padding" Value ="4,8,4,8" />
        <Setter Property="Margin" Value="4" />
    </Style>

    <Style x:Key="PaperListBoxStyle" TargetType="ListBox">
        <Setter Property="Margin" Value="4px" />
    </Style>

    <!-- Button Styles -->
    <Style x:Key="PaperButtonStyle" TargetType="Button">
        <Setter Property="Background" Value="WhiteSmoke" />
        <Setter Property="FontFamily" Value="Consolas, Courier New" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Padding" Value="4, 4, 4, 4" />
        <Setter Property="Width" Value="Auto" />
        <Setter Property="Height" Value="25px" />
        <Setter Property="MinWidth" Value="75px" />
        <Setter Property="Margin" Value="2px" />
    </Style>

    <Style x:Key="PaperTreeButtonStyle" BasedOn="{StaticResource PaperButtonStyle}" TargetType="Button"></Style>

    <Style x:Key="PaperBrowseButtonStyle" BasedOn="{StaticResource PaperButtonStyle}" TargetType="Button">
        <Setter Property="Width" Value="25px" />
    </Style>

    <Style x:Key="PaperToolbarButtonStyle" TargetType="Button" BasedOn="{StaticResource PaperButtonStyle}">
        <Setter Property="Width" Value="25px" />
        <Setter Property="MinWidth" Value="25px" />
        <Setter Property="Padding" Value="2, 2, 2, 2" />
    </Style>

    <Style x:Key="CommandItemStyle"></Style>

    <Style x:Key="NameTextBlockStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
    </Style>

    <Style x:Key="TreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <DataTemplate x:Key="CommandItemTemplate" DataType="{x:Type mvvm:CommandViewModel}">
        <Border Style="{StaticResource ToolsBorderStyle}">
            <Button Command="{Binding Command}" Content="{Binding DisplayName}" />
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="EntityCommandItemTemplate" DataType="{x:Type entity:EntityCommandViewModel}">
        <Border Style="{StaticResource ToolsBorderStyle}">
            <Button Command="{Binding Path=Command}" Content="{Binding Path=DisplayName}" />
        </Border>
    </DataTemplate>

    <!-- Entity Editor templates -->

    <DataTemplate DataType="{x:Type entity:EditableModuleViewModel}">
        <view:EditModule />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableMultispriteViewModel}">
        <view:EditableMultispriteView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableFramesetListViewModel}">
        <view:EditableFramesetListView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableFramesetViewModel}">
        <view:EditableFramesetView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableFrameViewModel}">
        <view:EditableFrameView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableLayeredMapViewModel}">
        <view:EditableLayeredMapView />
    </DataTemplate>

    <DataTemplate DataType="{x:Type entity:EditableMapLayerViewModel}">
        <view:EditableMapLayerView />
    </DataTemplate>

    <DataTemplate x:Key="EditorInvokingNameDisplay" DataType="{x:Type entity:IEntityViewModel}">
        <Grid>
            <TextBlock Text="{Binding Path=Entity.Name, Mode=OneWay}" Visibility="{Binding Path=NodeDisplayVisibility, Mode=OneWay}">
              <TextBlock.InputBindings>
                <KeyBinding Command="{Binding Path=BeginRenameCommand}" Key="F2" />
                <KeyBinding Command="{Binding Path=DeleteCommand}" Key="Delete" />
                <MouseBinding Command="{Binding Path=BeginRenameCommand}" MouseAction="LeftDoubleClick" />
              </TextBlock.InputBindings>
            </TextBlock>
            <TextBox Text="{Binding Path=Entity.Name, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" Visibility="{Binding Path=NodeEditorVisibility, Mode=OneWay}">
                <TextBox.InputBindings>
                    <KeyBinding Command="{Binding Path=EndRenameCommand}" Key="Enter" />
                    <KeyBinding Command="{Binding Path=EndRenameCommand}" Key="Tab" />
                </TextBox.InputBindings>
            </TextBox>
        </Grid>
    </DataTemplate>

    <HierarchicalDataTemplate x:Key="EntityNameNodeTemplate" DataType="{x:Type entity:IEntityCollectionViewModel}"
                              ItemsSource="{Binding Path=ViewModels}">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
            <ContentControl ContentTemplate="{StaticResource EditorInvokingNameDisplay}" Content="{Binding}" />
            <Button Content="+" Command="{Binding AddChildCommand.Command}" Visibility="{Binding Path=AddChildCommandVisibility}" Style="{StaticResource PaperToolbarButtonStyle}" />
            <Button Content="-" Command="{Binding DeleteCommand}" Style="{StaticResource PaperToolbarButtonStyle}" />
        </StackPanel>
    </HierarchicalDataTemplate>


    <DataTemplate x:Key="ListHeaderTemplate">
        <Border Style="{StaticResource HeaderBorderStyle}">
            <TextBlock Text="{Binding}" HorizontalAlignment="Center" />
        </Border>
    </DataTemplate>

    <DataTemplate x:Key="ResortableListTemplate">
        <ListBox ItemsSource="{Binding}" ItemsControl.ItemTemplate="{StaticResource EditorInvokingNameDisplay}" />
    </DataTemplate>

</ResourceDictionary>